<template>
	<view>
		<uni-head title="理赔上传"></uni-head>
		<view class="searchBox flex">
			<view class="fdjbox">
				<image src="../../static/fdj.png" mode=""></image>
			</view>
			<view class="inpbox">
				<input type="text" value="" v-model="key_words" placeholder="输入出险人姓名、身份证号" placeholder-style="color:#BBBBBB;font-size: 28upx;	margin-top: 4upx;"/>
				
			</view>
		</view>
		<view class="titletext">请选择需要出险的保单</view>
		<view class="itembox" v-for="(item,index) in itemdata" :key="index"  @click="navclick(item.id)">
			<view class="bxtitle">{{item.bx_name}}</view>
			<view class="Insurer">被保险人：{{item.insure}}</view>
			<view class="period">保障期限：{{item.start_time}}至{{item.end_time}}</view>
		</view>
		<view class="jiazai" v-if="isshow">
			我可是有底线的喔~
		</view>
	</view>
</template>

<script>
	import uniHead from "@/components/uni-dead/head.vue";
	import {navTo} from '@/utils/method.js'
	export default {
		components: { uniHead },
		data() {
			return {
				itemdata:[],//初始数据
				page:1,//初始页码
				key_words:'',//搜索框
				isshow:false,//到底
			}
		},
		onLoad() {
			this.reportorder()
		},
		onReachBottom(){
		  console.log('触底');
		  if(this.page!=this.last_page){
			  this.page++
			  this.reportorder(1)
			  console.log('执行');
		  }else{
			  this.isshow=true
		  }
		},
		watch:{
			key_words:{
				handler(){
					console.log(this.page);
					this.page=1
					this.reportorder(1)
				}
			}
		},
		methods: {
			// 进入详情
			navclick(id){
				let obj ={
					id,
					// show:true
				}
				navTo('/pages/order/upfile?obj='+JSON.stringify(obj))
			},
			// 初始数据方法
			reportorder(info){
				// 有传值的
				if(info==1){
					this.ajax('report/index',{
						data:{
							page:this.page,
							state:2,
							key_words:this.key_words
						},
						success:(res) => {
							console.log('分页');
							
							this.page=res.msg.current_page
							this.last_page=res.msg.last_page
							if(res.msg.data.length==0){
								this.itemdata=res.msg.data
							}else{
								res.msg.data.forEach((i)=>{
									this.itemdata.push(i)
								})
							}
							
							console.log(this.itemdata);
						}
					})
				}else{
					// 没有传值的初始
					this.ajax('report/index',{
						data:{
							state:2
						},
						success:(res) => {
							console.log(res);
							
							this.last_page=res.msg.last_page
							this.page=res.msg.current_page
							this.itemdata=res.msg.data
						}
					})
				}
			}
		}
	}
</script>

<style scoped lang="less">
.searchBox{
	margin: 30upx 24upx;
	height: 72upx;
	background-color: #fff;
	border-radius: 20upx;
	.fdjbox{
		width: 32upx;
		height: 32upx;
		
		margin-left: 26upx;
		image{
			width: 32upx;
			height: 32upx;
		}
	}
	.inpbox{
		margin-left: 22upx;
		input{
			width: 580upx;
			font-size: 28upx;
		}
	}
}
.titletext{
		margin:40upx 24upx 0;
		height: 50rpx;
		color: #000000;
		font-size: 32upx;
	}
	.itembox{
		margin:42upx 24upx 0;
		border-radius: 20upx;
		background-color: #fff;
		position: relative;
		.bxtitle{
			padding-top:34upx ;
			margin-left: 28upx;
			font-size: 32upx;
			color: #000000;
		}
		.Insurer{
			margin:26upx 28upx 0 ;
			font-size: 28upx;
			color: #999999;
		}
		.period{
			margin:26upx 28upx 0 ;
			padding-bottom: 38upx;
			font-size: 28upx;
			color: #999999;
		}
		.checkbox{
			width: 48upx;
			height: 48upx;
			border: 1px solid #CCCCCC;
			border-radius: 10upx;
			position: absolute;
			right: 36upx;
			top: 92upx;
		}
		.duigoimg{
			width: 50upx;
			height: 50upx;
			position: absolute;
			right: 36upx;
			top: 92upx;
		}
	}
	.butbox{
		margin:172upx 28upx 60upx ;
		height: 100upx;
		background: linear-gradient(180deg, #4EB4FE 0%, #5280F8 100%);
		border-radius: 10upx;
		text-align: center;
		line-height: 100upx;
		color: #fff;
		font-size: 32upx;
		// display: flex;
		// padding: 0 0 30upx 0;
	}
	.jiazai{
		// height: 40upx;
		padding: 20upx 0;
		color:#777777;
		text-align: center;
		font-size: 28upx;
	}
</style>
